import request from "./index";

/**
 * 获取密保列表
 * @returns {Promise}
 */
export function getSecretList() {
  return request({
    url: "/secret/list"
  })
}

/**
 * 删除一个密保
 * @param secretId {string}
 * @returns {Promise}
 */
export function deleteSecret(secretId) {
  return request({
    url: "/secret",
    method: "DELETE",
    data: {
      secretId
    }
  })
}

/**
 * 修改一个密保
 * @param secretId {string | number}
 * @param question {string}
 * @param answer{string}
 * @returns {Promise}
 */
export function updateSecret(secretId, question, answer) {
  return request({
    url: "/secret",
    method: "PATCH",
    data: {
      secretId,
      question,
      answer
    }
  })
}

/**
 * 新增一个密保
 * @param question {string}
 * @param answer {string}
 * @returns {Promise}
 */
export function createSecret(question, answer) {
  return request({
    url: "/secret",
    method: "POST",
    data: {
      question,
      answer
    }
  })
}

